ARG PHP_VERSION
FROM php:${PHP_VERSION}

ARG TZ
ARG PHP_EXTENSIONS
ARG DEBIAN_MIRROR_DOMAIN

ENV TZ=${TZ}

COPY ./install-php-extensions /usr/local/bin/install-php-extensions

RUN sed -i "s|deb.debian.org|${DEBIAN_MIRROR_DOMAIN}|g" /etc/apt/sources.list.d/debian.sources \
    && export option="--no-install-recommends -y" \
    && apt-get $option update \
    && apt-get $option install tzdata curl \
    && apt-get clean && rm -rf /var/lib/apt/lists/* \
    && chmod +x /usr/local/bin/install-php-extensions \
    && install-php-extensions $PHP_EXTENSIONS \
    && curl -sSLf -o /usr/local/bin/composer https://mirrors.tencent.com/composer/composer.phar \
    && chmod 755 /usr/local/bin/composer \
    && composer config -g repos.packagist composer https://mirrors.tencent.com/composer/

ENV COMPOSER_HOME=/tmp/composer

WORKDIR /www